package indi.zhifa.study2024.nbr.busycore.logic.report.consign.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import indi.zhifa.study2024.nbr.busycore.logic.report.consign.IConsignService;
import indi.zhifa.study2024.nbr.busycore.logic.report.consign.entity.mapperIn.ConsignMapperIn;
import indi.zhifa.study2024.nbr.busycore.logic.report.consign.entity.mapperOut.ConsignMapperOut;
import indi.zhifa.study2024.nbr.busycore.logic.report.consign.entity.request.ConsignPageRequest;
import indi.zhifa.study2024.nbr.busycore.logic.report.consign.mapper.ConsignMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@RequiredArgsConstructor
@Component
public class ConsignServiceImpl implements IConsignService {

    final ConsignMapper mConsignMapper;

    @Override
    public Page<ConsignMapperOut> pageGroupByItemId(ConsignPageRequest pConsignPageRequest) {
        Page<ConsignMapperOut> pageCfg = new Page<>(pConsignPageRequest.getCurrent(),pConsignPageRequest.getSize());
        ConsignMapperIn consignMapperIn = pConsignPageRequest.toMapperIn();
        long curTime = System.currentTimeMillis();
        Page<ConsignMapperOut> consignMapperOutPage = mConsignMapper.page(pageCfg, consignMapperIn);
        long endTime = System.currentTimeMillis();
        log.info("cost time "+(endTime - curTime)/1000.0 + "s");
        return consignMapperOutPage;
    }
}
